package com.example.pixelyear.utils;

import android.util.Log;

/**
 * Package    : com.zjedu.xueyuan.utils
 * ClassName  : NumberUtils
 * Description: ${TODO}
 * Author     : 坐怀不乱
 * Date       : 2018/5/10 9:06
 */

public class NumberUtils {
    public static final int ZERO = 0;
    public static final int ONE = 1;
    public static final int TWO = 2;
    public static final int THREE = 3;
    public static final int FOUR = 4;
    public static final int FIVE = 5;
    public static final int SIX = 6;
    public static final int SEVEN = 7;
    public static final int EIGHT = 8;
    public static final int NINE = 9;
    public static final int MAX = 999;


    public static String numToABC(int i) {
        if (i < 0 || i >= 26) {
            return "";
        }
        String words = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char[] mChar = words.toCharArray();
        return String.valueOf(mChar[i]);
    }

    public static int parseInt(String num) {
        if (num == null || num.isEmpty())
            return 0;
        else {
            try {
                return Integer.parseInt(num);
            } catch (NumberFormatException ignore) {
                return 0;
            }
        }
    }

    public static float parseFloat(String num) {
        if (num == null || num.isEmpty())
            return 0f;
        else {
            try {

                return Float.valueOf(num);
            } catch (NumberFormatException ignore) {
                return 0f;
            }
        }
    }

    public static int translateWeek(String week) {
        switch (week) {
            case "周一":
                return 1;
            case "周二":
                return 2;
            case "周三":
                return 3;
            case "周四":
                return 4;
            case "周五":
                return 5;
            case "周六":
                return 6;
            case "周日":
                return 7;
            default:
                return 0;
        }
    }

    public static String translateWeek(int week) {
        switch (week) {
            case 1:
                return "一";
            case 2:
                return "二";
            case 3:
                return "三";
            case 4:
                return "四";
            case 5:
                return "五";
            case 6:
                return "六";
            case 7:
                return "日";
            default:
                return "零";
        }
    }

}
